package com.ruoyi.web.controller.park;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.park.domain.CompanySignContract;
import com.ruoyi.park.domain.PersonSignContract;
import com.ruoyi.park.service.ICompanySignContractService;
import com.ruoyi.park.service.IPersonSignContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("/person/sign/contract")
public class PersonSignContractController extends BaseController {

    @Autowired
    IPersonSignContractService personSignContractService;

    /**
     * 获取列表
     */
    @GetMapping("/pageList")
    public IPage list(PersonSignContract personSignContract, @RequestParam Long pageNo, @RequestParam Long pageSize)
    {
        IPage<PersonSignContract> page = new Page(pageNo,pageSize);
        IPage list = personSignContractService.page(page,new QueryWrapper<>(personSignContract));
        return list;
    }
    /**
     * 新增
     */
    @GetMapping("{id}")
    public AjaxResult getById(@PathVariable Long id)
    {
        return AjaxResult.success(personSignContractService.getById(id));
    }


    /**
     * 新增
     */
    @PostMapping
    public AjaxResult add(@Validated @RequestBody PersonSignContract personSignContract)
    {
        return toAjax(personSignContractService.save(personSignContract));
    }

    /**
     * 修改
     */
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody PersonSignContract personSignContract)
    {
        return toAjax(personSignContractService.updateById(personSignContract));
    }

    /**
     * 删除
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(personSignContractService.removeByIds(Arrays.asList(ids)));
    }

}
